package(default_visibility=["//visibility:public"])

load("@io_bazel_rules_sass//sass:sass.bzl", "sass_library", "sass_binary")
load("//:packages.bzl", "MATERIAL_PACKAGES")
load("//tools:defaults.bzl", "ng_module", "ng_test_library", "ng_web_test_suite")

exports_files(["theming/_theming.scss"])

ng_module(
  name = "core",
  srcs = glob(["**/*.ts"], exclude=["**/*.spec.ts"]),
  module_name = "@angular/material/core",
  assets = [
    ":selection/pseudo-checkbox/pseudo-checkbox.css",
    ":option/option.css",
    ":option/optgroup.css",
  ] + glob(["**/*.html"]),
  deps = [
    "@angular//packages/common",
    "@angular//packages/core",
    "@angular//packages/forms",
    "@angular//packages/platform-browser",
    "@angular//packages/platform-browser/animations",
    "@rxjs",
    "//src/cdk/a11y",
    "//src/cdk/bidi",
    "//src/cdk/coercion",
    "//src/cdk/keycodes",
    "//src/cdk/platform",
  ],
)

# TODO(jelbourn): remove this when sass_library acts like a filegroup
filegroup(
  name = "core_scss_partials",
  srcs = glob([
    "**/_*.scss"
  ], exclude = ["theming/_all-theme.scss"]),
)

# Library of all core scss partials.
sass_library(
  name = "core_scss_lib",
  srcs = [":core_scss_partials"],
  deps = [
    "//src/cdk/a11y:a11y_scss_lib",
    "//src/cdk/overlay:overlay_scss_lib",
    "//src/cdk/text-field:text_field_scss_lib",
  ],
)

sass_binary(
  name = "pseudo_checkbox_scss",
  src = "selection/pseudo-checkbox/pseudo-checkbox.scss",
  deps = [":core_scss_lib"],
)

sass_binary(
  name = "option_scss",
  src = "option/option.scss",
  deps = [":core_scss_lib"],
)

sass_binary(
  name = "optgroup_scss",
  src = "option/optgroup.scss",
  deps = [":core_scss_lib"],
)

sass_library(
  name = "all_themes",
  srcs = [
    "theming/_all-theme.scss",
    "typography/_all-typography.scss",
  ],
  deps = [":core_scss_lib"] + ["//src/lib/%s:theme" % p for p in MATERIAL_PACKAGES],
)

sass_binary(
  name = "indigo_pink_prebuilt",
  src = "theming/prebuilt/indigo-pink.scss",
  deps = [":all_themes"],
)

sass_binary(
  name = "deeppurple-amber_prebuilt",
  src = "theming/prebuilt/deeppurple-amber.scss",
  deps = [":all_themes"],
)

sass_binary(
  name = "pink-bluegrey_prebuilt",
  src = "theming/prebuilt/pink-bluegrey.scss",
  deps = [":all_themes"],
)

sass_binary(
  name = "purple-green_prebuilt",
  src = "theming/prebuilt/purple-green.scss",
  deps = [":all_themes"],
)

# This rule exists so that we can use MATERIAL_PACKAGES to enumerate all themes.
sass_library(
  name = "theme",
  srcs = glob(["**/*-theme.scss"]),
)

#################
#  Test targets
#################

ng_test_library(
  name = "core_test_sources",
  srcs = glob(["**/*.spec.ts"]),
  deps = [
    "@angular//packages/platform-browser",
    "@angular//packages/platform-browser/animations",
    "//src/cdk/platform",
    "//src/cdk/testing",
    "//src/lib/core",
  ]
)

ng_web_test_suite(
  name = "unit_tests",
  deps = [":core_test_sources"],
)
